using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using System;
namespace MicroMsg.Scene
{
	public class NetSceneLogout
	{
		private const string TAG = "NetSceneLogout";
		private EventWatcher mUnregWatcher;
		public void doScene()
		{
			if (this.mUnregWatcher != null)
			{
				Log.smethod_1("NetSceneLogout", " logout already.");
				return;
			}
			Log.smethod_4("NetSceneLogout", "logout startup... username = " + AccountMgr.getCurAccount().strUsrName);
			this.mUnregWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onUnRegOverHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_PUSHCHANNEL_UNREG_OVER, this.mUnregWatcher);
			if (!ServiceCenter.scenePushChannelUnReg.doScene())
			{
				this.doFinished();
			}
		}
		private void onUnRegOverHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.doFinished();
		}
		private void doFinished()
		{
			if (this.mUnregWatcher != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_PUSHCHANNEL_UNREG_OVER, this.mUnregWatcher);
				this.mUnregWatcher = null;
			}
			Log.smethod_4("NetSceneLogout", "logout over... username = " + AccountMgr.getCurAccount().strUsrName);
			EventCenter.postEvent(EventConst.ON_NETSCENE_LOGOUT_OVER, null, null);
		}
	}
}
